package com.yang.concurrency.chapter2;

/**
 * @Author: 血魔
 * @Date: Created in 11:34 2021/12/12
 * @Version: 1.0$
 */
public class TicketWindow extends Thread{

    private final static int MAX = 50;
    private String name;

    private static int index = 0;

    public TicketWindow(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        while (index <= MAX) {
            try{
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("当前的号码是："+(index++)+"取到当前号码的线程为"+Thread.currentThread().getName()+" 买到票的人叫：" + this.name);
        }

    }
}
